home *** CD-ROM | disk | FTP | other *** search
- <xsl:stylesheet
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- version="1.0">
- <xsl:output method="xml" indent="yes" encoding="utf-8" />
-
- <xsl:template match="/">
- <Repeats>
- <xsl:apply-templates select="*" />
- </Repeats>
- </xsl:template>
-
- <xsl:template match="*">
- <xsl:if test="(*[1] | @*[1] | text()) and name() != name(preceding-sibling::*[1])">
- <xsl:variable name="repeating" select="following-sibling::*[name() = name(current())]"/>
- <xsl:if test="count($repeating)">
- <xsl:variable name="XPath">
- <xsl:call-template name="GetXPath" />
- </xsl:variable>
- <Repeat Name="{name()}" Path="{$XPath}" />
- </xsl:if>
- <xsl:apply-templates select="*"/>
- </xsl:if>
- </xsl:template>
-
- <xsl:template match="@*|text()|comment()|processing-instruction()"/>
-
- <xsl:template name="GetXPath">
- <xsl:for-each select="ancestor-or-self::*">
- <xsl:text>/</xsl:text>
- <xsl:value-of select="name()" />
- </xsl:for-each>
- </xsl:template>
-
- </xsl:stylesheet>
-